/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controllers;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import vo.PropertiesVO;

/**
 *
 * @author Jhovany Amaya
 */
public class FileLogServiceControl {
    
    private static final String HOST = "FILELOG_HOST";
    private static final String PORT = "FILELOG_PORT";
    private static final String RESOURCE = "FILELOG_RESOURCE";
    private String serviceLocation;
    private URL url = null;

    public FileLogServiceControl() {
        try {
            PropertiesControl.setHOST(HOST);
            PropertiesControl.setPORT(PORT);
            PropertiesControl.setRESOURCE(RESOURCE);
            PropertiesVO p = PropertiesControl.localProperties();
            serviceLocation = "http://" + p.getHost() + ":" + p.getPort().toString() + p.getResource();
            url = new URL(serviceLocation);
        } catch (MalformedURLException malformedURLException) {
            System.out.println("direccion invalida");
        } catch (IOException e) {
            System.out.println("ARCHIVO PROPERTIES FALLO");
            serviceLocation = "http://localhost:8080/FileLogSWS/FileLogSWS?wsdl";
            try {
                url = new URL(serviceLocation);
            } catch (MalformedURLException ex) {
                System.out.println("direccion invalida");
                Logger.getLogger(LoginServiceControl.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
    public String headerFile(java.lang.String bid, java.lang.String eid){
        ws.filelog.FileLogSWS_Service service = new ws.filelog.FileLogSWS_Service(url);
        ws.filelog.FileLogSWS port = service.getFileLogSWSPort();
        return port.headerFile(bid, eid);
    }
    
    public int footerFile(java.lang.String fid){
        ws.filelog.FileLogSWS_Service service = new ws.filelog.FileLogSWS_Service(url);
        ws.filelog.FileLogSWS port = service.getFileLogSWSPort();
        return port.footerFile(fid);
    }
    
}
